package org.openstreetmap.josm.plugins.cadastre_es;

import static org.openstreetmap.josm.tools.I18n.tr;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.gui.MainMenu;
import org.openstreetmap.josm.plugins.Plugin;
import org.openstreetmap.josm.plugins.PluginInformation;
import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.tools.Shortcut;

public class CadastrePlugin extends Plugin {
    public static ProgressFrame progressFrame;
    
	public CadastrePlugin(PluginInformation info) {
	    super(info);
	    MainMenu.add(Main.main.menu.toolsMenu, new CadastreAction());
	} 
    
    private class CadastreAction extends JosmAction {
        private static final long serialVersionUID = 5103382298252385393L;

        /** Set up the action (text appearing on the menu, keyboard shortcut etc */
        public CadastreAction() {
            super(tr("Import buildings"),
                  "cadastre-select",
                  tr("Import buildings from spanish cadastre"),
                  Shortcut.registerShortcut("cadastre-es:import", tr("Import buildings"), KeyEvent.VK_C, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT),
                  true);
        }

        public void actionPerformed(ActionEvent ev) {
            progressFrame = new ProgressFrame();
            new Process().start();
        }

        /**
         * Update the enabled state of the action when something in
         * the JOSM state changes, i.e. when a layer is removed or
         * added.
         */
        @Override
        protected void updateEnabledState() {
            setEnabled(Main.main.getCurrentDataSet() != null);
        }
    }
    
    /*@Override
    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
        if (newFrame == null){
            //ContourMergeModelManager.getInstance().unwireFromJOSM();
            //ContourMergeView.getInstance().unwireFromJOSM();
        } else {
            //newFrame.addMapMode(new IconToggleButton(mode = new ContourMergeMode(newFrame)));
            //ContourMergeModelManager.getInstance().wireToJOSM();
            //ContourMergeView.getInstance().wireToJOSM();
        }
    }*/ 
}
